package com.github.lee.unsplash.ui.web

import android.content.Context
import androidx.activity.viewModels
import androidx.core.os.bundleOf
import com.github.lee.core.common.ext.getBundleValue
import com.github.lee.core.common.normalIntent
import com.github.lee.mvvm.core.ui.web.BaseWebViewActivity
import com.github.lee.mvvm.core.ui.web.BaseWebViewVM

class WebViewActivity : BaseWebViewActivity<BaseWebViewVM>() {


    companion object {
        private const val KEY_URL = "URL"
        private const val KEY_TITLE = "TITLE"

        fun start(context: Context, url: String, title: String? = null) {
            context.startActivity(
                normalIntent(context, WebViewActivity::class.java)
                    .putExtras(
                        bundleOf(KEY_URL to url, KEY_TITLE to title)
                    )
            )
        }
    }


    //===Desc:=========================================================


    override fun onCreateViewModel(): BaseWebViewVM =
        viewModels<BaseWebViewVM>().value

    override fun getLoadUrl(): String =
        getBundleValue(KEY_URL, "") ?: ""


}